< previous page page_17 next page >

Page 17
0017-01.jpg
Figure 1.8
Example program Pie uses the PieSlice subroutine
to make drawing pie slices easier.
The Circle method can also draw ellipses. If you set the method's aspect parameter to a value other than 1.0, Visual Basic draws an ellipse with that height/width ratio. Circle draws an ellipse with major (longer) axis of length 2 * radius, and it adjusts the minor (shorter) axis to give the ellipse the correct aspect ratio. Figure 1.9 shows a circle surrounding an ellipse with aspect ratio 2.0. These shapes were drawn with the following commands.
e10a6a0a59f035e870d90cca05b85fce.gif
Circle (50, 50), 20 
Circle (50, 50), 20, , , , 2.0
One drawback to the Circle method is that it does not honor custom coordinate systems. If you omit the aspect parameter or set it to 1.0, the Circle method draws a circle with a width equal to 2 * radius. It then gives the circle the same height on the screen. This result may not agree with your custom coordinate system.
For instance, suppose you have a square form and you have defined a custom coordinate system with the command Scale (0, 0)-(200, 100). If you then draw a circle with radius 20, you expect the circle's width and height to be 40 units in the custom coordinate system. Because the custom coordinate system contains 200 units horizontally and only 100 units vertically, you expect the circle to be taller than it is wide.
The Circle method, however, makes the circle 40 units wide and then adjusts the circle's height so that it is round on the screen. If the Circle method honored the custom coordinate system, the box and circle drawn with the following commands would have the same height and width. Because it does not, these commands produce a round circle inside a taller rectangle with the same width.
e10a6a0a59f035e870d90cca05b85fce.gif
Line (80, 30)-(120, 70), , B
Circle (100, 50), 20

 
< previous page page_17 next page >